// Written by Steve Andersen, copyright (c) 2007 ONE/Northwest
// This program is released under the GNU General Public License. http://www.gnu.org/licenses/

public class ONEN_DefaultAccount {
 
//  new defaultAccount lookup class whose SOQL should only have to be run once
// per trigger chain

	//variable for Account Id
	// this has to be public & static for this to work
	public static Id IndividualAccountId; 

	//variable for Account Name
	private static String IndividualAccountName = ONEN_Constants.INDIVIDUAL_ACCOUNT_NAME;

	public static id GetIndividualAccountId () {
	
		// look up the ID if we haven't already done it
		if ( IndividualAccountId == null ) {
			Account acct = [select id from account where Name =:IndividualAccountName LIMIT 1];
			IndividualAccountId = acct.id;
		}
			
		return IndividualAccountId;

	}


/*  original code (prior to 11/8/07), deprecated
	//variable for Account Name
	private String IndividualAccountName;
	//variable for Account Id
	private Id IndividualAccountId; 
	
	//constructor where no account name is passed in
	public DefaultAccount () {
		IndividualAccountName = Constants.INDIVIDUAL_ACCOUNT_NAME;
		assignDefaultAccountId();
		
	}
	//constructor where account name is passed in
	public DefaultAccount (String defAccountName) {
		IndividualAccountName = defAccountName;
		assignDefaultAccountId();
	}
	
	//method for getting the Account Id, called in constructor
	private void assignDefaultAccountId () {
		Account[] account = [select id from account where Name =:IndividualAccountName];
		//if we retun an account, use the Id, otherwise leave it null
		if (account.size()>0) {
			IndividualAccountId = account[0].Id;
		} else {
			IndividualAccountId =null; 
		}
	}
	
	//method for getting the Account Id
	public Id getDefaultAccountId () {
		return IndividualAccountId;
	}
*/


}